package com.fqcar.fqdf.ui.main.holder;

import android.content.Context;

import com.fqcar.fqdf.core.cache.HomeSelectKey;
import com.fqcar.fqdf.ui.chargemap.holder.StubForUseChargeHolder;
import com.fqcar.fqdf.ui.chargemap.holder.StubForUseHolder;
import com.fqcar.fqdf.ui.chargemap.holder.StubForUseSelChargeHolder;
import com.fqcar.fqdf.ui.chargemap.holder.StubForUseSelHolder;
import com.fqdf.framework.android.activity.holder.BaseOverlayHolder;


public class MainHolderHelper {

    private CarForRentHolder carForRentHolder;
    private CarForRentSelHolder carForRentSelHolder;
    private CarForRentPercentHolder carForRentPercentHolder;
    private CarForRentPercentSelHolder carForRentPercentSelHolder;
    private CarOfflineHolder carOfflineHolder;
    private CarOfflineSelHolder carOfflineSelHolder;
    private CarRepairHolder carRepairHolder;
    private CarRepairSelHolder carRepairSelHolder;
    private CarLowPowerHolder carLowPowerHolder;
    private CarLowPowerSelHolder carLowPowerSelHolder;
    private CarLowPowerPercentHolder carLowPowerPercentHolder;
    private CarLowPowerPercentSelHolder carLowPowerPercentSelHolder;

    private CarForRentChargeHolder carForRentChargeHolder;
    private CarForRentChargeSelHolder carForRentChargeSelHolder;
    private CarOfflineChargeHolder carOfflineChargeHolder;
    private CarOfflineSelChargeHolder carOfflineSelChargeHolder;
    private CarRepairChargeHolder carRepairChargeHolder;
    private CarRepairSelChargeHolder carRepairSelChargeHolder;
    private CarLowPowerChargeHolder carLowPowerChargeHolder;
    private CarLowPowerChargeSelHolder carLowPowerChargeSelHolder;
    private CarLowPowerPercentChargeHolder carLowPowerPercentChargeHolder;
    private CarLowPowerPercentChargeSelHolder carLowPowerPercentChargeSelHolder;
    private CarForRentPercentChargeHolder carForRentPercentChargeHolder;
    private CarForRentPercentChargeSelHolder carForRentPercentChargeSelHolder;

    private StubForUseHolder stubForUseHolder;
    private StubForUseChargeHolder stubForUseChargeHolder;
    private StubForUseSelHolder stubForUseSelHolder;
    private StubForUseSelChargeHolder stubForuseSelChargeHolder;

//    private StubNotUseHolder stubNotUseHolder;
//    private StubNotUseSelHolder stubNotUseSelHolder;

    private Context mContext;

    public MainHolderHelper(Context context) {
        mContext = context;
    }


    /**
     * 前期先写死判断， 之后有时间需要改成 按位进行与或操作 简化判断流程
     *
     * @param key
     * @return
     */
    public BaseOverlayHolder getCarHolderByKey(HomeSelectKey key) {

        BaseOverlayHolder baseOverlayHolder = null;

        if(key.isForRent()){
            if(!key.isSelect()){
                if(key.isCharging()){
                    CarForRentChargeHolder holder = getCarForRentChargeHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarForRentHolder holder = getCarForRentHolder();
                    baseOverlayHolder = holder;
                }
            }else {
                if(key.isCharging()){
                    CarForRentChargeSelHolder holder = getCarForRentChargeSelHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarForRentSelHolder holder = getCarForRentSelHolder();
                    baseOverlayHolder = holder;
                }
            }
        }else if(key.isForRentPer()){
            if(!key.isSelect()){
                if(key.isCharging()){
                    CarForRentPercentChargeHolder holder = getCarForRentPercentChargeHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarForRentPercentHolder holder = getCarForRentPercentHolder();
                    baseOverlayHolder = holder;
                }
            }else {
                if(key.isCharging()){
                    CarForRentPercentChargeSelHolder holder = getCarForRentPercentChargeSelHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarForRentPercentSelHolder holder = getCarForRentPercentSelHolder();
                    baseOverlayHolder = holder;
                }
            }
        }else if(key.isOffline()){
            if(!key.isSelect()){
                if(key.isCharging()){
                    CarOfflineChargeHolder holder = getCarOfflineChargeHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarOfflineHolder holder = getCarOfflineHolder();
                    baseOverlayHolder = holder;
                }
            }else {
                if(key.isCharging()){
                    CarOfflineSelChargeHolder holder = getCarOfflineSelChargeHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarOfflineSelHolder holder = getCarOfflineSelHolder();
                    baseOverlayHolder = holder;
                }
            }
        }else if(key.isRepair()){
            if(!key.isSelect()){
                if(key.isCharging()){
                    CarRepairChargeHolder holder = getCarRepairChargeHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarRepairHolder holder = getCarRepairHolder();
                    baseOverlayHolder = holder;
                }
            }else {
                if(key.isCharging()){
                    CarRepairSelChargeHolder holder = getCarRepairSelChargeHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarRepairSelHolder holder = getCarRepairSelHolder();
                    baseOverlayHolder = holder;
                }
            }
        }else if(key.isLowPowerOffline()){
            if(!key.isSelect()){
                if(key.isCharging()){
                    CarLowPowerChargeHolder holder = getCarLowPowerChargeHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarLowPowerHolder holder = getCarLowPowerHolder();
                    baseOverlayHolder = holder;
                }
            }else {
                if(key.isCharging()){
                    CarLowPowerChargeSelHolder holder = getCarLowPowerChargeSelHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarLowPowerSelHolder holder = getCarLowPowerSelHolder();
                    baseOverlayHolder = holder;
                }
            }
        }else if(key.isLowPowerPercentOffline()){
            if(!key.isSelect()){
                if(key.isCharging()){
                    CarLowPowerPercentChargeHolder holder = getCarLowPowerPercentChargeHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarLowPowerPercentHolder holder = getCarLowPowerPercentHolder();
                    baseOverlayHolder = holder;
                }
            }else {
                if(key.isCharging()){
                    CarLowPowerPercentChargeSelHolder holder = getCarLowPowerPercentChargeSelHolder();
                    baseOverlayHolder = holder;
                }else {
                    CarLowPowerPercentSelHolder holder = getCarLowPowerPercentSelHolder();
                    baseOverlayHolder = holder;
                }
            }
        }else if(key.isStubForUseCharing()){
            if(!key.isSelect()){
                StubForUseChargeHolder holder = getStubForUseChargeHolder();
                baseOverlayHolder = holder;
            }else {
                StubForUseSelChargeHolder holder = getStubForUseSelChargeHolder();
                baseOverlayHolder = holder;
            }
        }else if(key.isStubForUse()){
            if(!key.isSelect()){
                StubForUseHolder holder = getStubForUseHolder();
                baseOverlayHolder = holder;
            }else {
                StubForUseSelHolder holder = getStubForUseSelHolder();
                baseOverlayHolder = holder;
            }
        }
        return baseOverlayHolder;
    }

    /*public BaseOverlayHolder getStubHolderByKey(HomeSelectKey key) {

        BaseOverlayHolder baseOverlayHolder = null;

        if(key.isStubCharging()){
            if(!key.isSelect()){
                StubForUseChargeHolder holder = getStubForUseChargeHolder();
                baseOverlayHolder = holder;
            }else {
                StubForUseSelChargeHolder holder = getStubForuseSelChargeHolder();
                baseOverlayHolder = holder;
            }
        }else if(!key.isStubCharging()){
            if(!key.isSelect()){
                StubForUseHolder holder = getStubForUseHolder();
                baseOverlayHolder = holder;
            }else {
                StubForUseSelHolder holder = getStubForUseSelHolder();
                baseOverlayHolder = holder;
            }
        }
        return baseOverlayHolder;
    }*/


    private CarForRentHolder getCarForRentHolder() {
        if (carForRentHolder == null) {
            carForRentHolder = new CarForRentHolder(mContext);
        }

        return carForRentHolder;
    }

    private CarForRentSelHolder getCarForRentSelHolder() {
        if (carForRentSelHolder == null) {
            carForRentSelHolder = new CarForRentSelHolder(mContext);
        }
        return carForRentSelHolder;
    }

    private CarOfflineHolder getCarOfflineHolder() {
        if (carOfflineHolder == null) {
            carOfflineHolder = new CarOfflineHolder(mContext);
        }
        return carOfflineHolder;
    }

    private CarOfflineSelHolder getCarOfflineSelHolder() {
        if (carOfflineSelHolder == null) {
            carOfflineSelHolder = new CarOfflineSelHolder(mContext);
        }
        return carOfflineSelHolder;
    }

    private CarRepairHolder getCarRepairHolder() {
        if (carRepairHolder == null) {
            carRepairHolder = new CarRepairHolder(mContext);
        }
        return carRepairHolder;
    }

    private CarRepairSelHolder getCarRepairSelHolder() {
        if (carRepairSelHolder == null) {
            carRepairSelHolder = new CarRepairSelHolder(mContext);
        }
        return carRepairSelHolder;
    }
    public CarForRentChargeHolder getCarForRentChargeHolder() {
        if(carForRentChargeHolder == null){
            carForRentChargeHolder = new CarForRentChargeHolder(mContext);
        }
        return carForRentChargeHolder;
    }

    public CarForRentChargeSelHolder getCarForRentChargeSelHolder() {
        if(carForRentChargeSelHolder == null){
            carForRentChargeSelHolder = new CarForRentChargeSelHolder(mContext);
        }
        return carForRentChargeSelHolder;
    }

    public CarOfflineChargeHolder getCarOfflineChargeHolder() {
        if(carOfflineChargeHolder == null){
            carOfflineChargeHolder = new CarOfflineChargeHolder(mContext);
        }
        return carOfflineChargeHolder;
    }

    public CarOfflineSelChargeHolder getCarOfflineSelChargeHolder() {
        if(carOfflineSelChargeHolder == null){
            carOfflineSelChargeHolder = new CarOfflineSelChargeHolder(mContext);
        }
        return carOfflineSelChargeHolder;
    }

    public CarRepairChargeHolder getCarRepairChargeHolder() {
        if(carRepairChargeHolder == null){
            carRepairChargeHolder = new CarRepairChargeHolder(mContext);
        }
        return carRepairChargeHolder;
    }

    public CarRepairSelChargeHolder getCarRepairSelChargeHolder() {
        if(carRepairSelChargeHolder == null){
            carRepairSelChargeHolder = new CarRepairSelChargeHolder(mContext);
        }
        return carRepairSelChargeHolder;
    }
    public CarLowPowerHolder getCarLowPowerHolder() {
        if(carLowPowerHolder == null){
            carLowPowerHolder = new CarLowPowerHolder(mContext);
        }
        return carLowPowerHolder;
    }

    public CarLowPowerSelHolder getCarLowPowerSelHolder() {
        if(carLowPowerSelHolder == null){
            carLowPowerSelHolder = new CarLowPowerSelHolder(mContext);
        }
        return carLowPowerSelHolder;
    }

    public CarLowPowerPercentHolder getCarLowPowerPercentHolder() {
        if(carLowPowerPercentHolder == null){
            carLowPowerPercentHolder = new CarLowPowerPercentHolder(mContext);
        }
        return carLowPowerPercentHolder;
    }

    public CarLowPowerPercentSelHolder getCarLowPowerPercentSelHolder() {
        if(carLowPowerPercentSelHolder == null){
            carLowPowerPercentSelHolder = new CarLowPowerPercentSelHolder(mContext);
        }
        return carLowPowerPercentSelHolder;
    }

    public CarLowPowerChargeHolder getCarLowPowerChargeHolder() {
        if(carLowPowerChargeHolder == null){
            carLowPowerChargeHolder = new CarLowPowerChargeHolder(mContext);
        }
        return carLowPowerChargeHolder;
    }

    public CarLowPowerChargeSelHolder getCarLowPowerChargeSelHolder() {
        if(carLowPowerChargeSelHolder == null){
            carLowPowerChargeSelHolder = new CarLowPowerChargeSelHolder(mContext);
        }
        return carLowPowerChargeSelHolder;
    }

    public CarLowPowerPercentChargeHolder getCarLowPowerPercentChargeHolder() {
        if(carLowPowerPercentChargeHolder == null){
            carLowPowerPercentChargeHolder = new CarLowPowerPercentChargeHolder(mContext);
        }
        return carLowPowerPercentChargeHolder;
    }

    public CarLowPowerPercentChargeSelHolder getCarLowPowerPercentChargeSelHolder() {
        if(carLowPowerPercentChargeSelHolder == null){
            carLowPowerPercentChargeSelHolder = new CarLowPowerPercentChargeSelHolder(mContext);
        }
        return carLowPowerPercentChargeSelHolder;
    }
    public CarForRentPercentHolder getCarForRentPercentHolder() {
        if(carForRentPercentHolder == null){
            carForRentPercentHolder = new CarForRentPercentHolder(mContext);
        }
        return carForRentPercentHolder;
    }

    public CarForRentPercentSelHolder getCarForRentPercentSelHolder() {
        if(carForRentPercentSelHolder == null){
            carForRentPercentSelHolder = new CarForRentPercentSelHolder(mContext);
        }
        return carForRentPercentSelHolder;
    }

    public CarForRentPercentChargeHolder getCarForRentPercentChargeHolder() {
        if(carForRentPercentChargeHolder == null){
            carForRentPercentChargeHolder = new CarForRentPercentChargeHolder(mContext);
        }
        return carForRentPercentChargeHolder;
    }

    public CarForRentPercentChargeSelHolder getCarForRentPercentChargeSelHolder() {
        if(carForRentPercentChargeSelHolder == null){
            carForRentPercentChargeSelHolder = new CarForRentPercentChargeSelHolder(mContext);
        }
        return carForRentPercentChargeSelHolder;
    }

    public StubForUseHolder getStubForUseHolder() {
        if(stubForUseHolder == null){
            stubForUseHolder = new StubForUseHolder(mContext);
        }
        return stubForUseHolder;
    }

    public StubForUseChargeHolder getStubForUseChargeHolder() {
        if(stubForUseChargeHolder == null){
            stubForUseChargeHolder = new StubForUseChargeHolder(mContext);
        }
        return stubForUseChargeHolder;
    }

    public StubForUseSelHolder getStubForUseSelHolder() {
        if(stubForUseSelHolder == null){
            stubForUseSelHolder = new StubForUseSelHolder(mContext);
        }
        return stubForUseSelHolder;
    }

    public StubForUseSelChargeHolder getStubForUseSelChargeHolder() {
        if(stubForuseSelChargeHolder == null){
            stubForuseSelChargeHolder = new StubForUseSelChargeHolder(mContext);
        }
        return stubForuseSelChargeHolder;
    }

    /*public StubNotUseHolder getStubNotUseHolder() {
        if(stubNotUseHolder == null){
            stubNotUseHolder = new StubNotUseHolder(mContext);
        }
        return stubNotUseHolder;
    }

    public StubNotUseSelHolder getStubNotUseSelHolder() {
        if(stubNotUseSelHolder == null){
            stubNotUseSelHolder = new StubNotUseSelHolder(mContext);
        }
        return stubNotUseSelHolder;
    }*/

}
